<template>
  <div>12345
    用户名 <input type="text" v-model="username">
    密码 <input type="password" v-model="password">
    <button @click="reg">注册</button>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name: "reg",
    data() {
      return {
        username:'',
        password:''
      }
    },
    methods: {
      reg() {
        axios.post(
          'http://127.0.0.1:8000/reg/',
          {username:this.username,password:this.password}
        ).then(res => {
          console.log(res.data)
          if(res.data.code===200){
            alert('注册成功')
            this.$router.push('/login')
          }

        })
      }
    }
  }
</script>

